
# ======================================================================
#                 todo: 业务数据首日first同步，首日【全量】
# ======================================================================

# ======================================================================
#                   todo：1. 编码字典表：base_dic（首日，全量）
# ======================================================================
/opt/module/sqoop/bin/sqoop import \
--connect jdbc:mysql://node101:3306/gmall \
--username root \
--password 123456 \
--target-dir /origin_data/gmall/db/base_dic/2024-01-06 \
--delete-target-dir \
--query "SELECT
  dic_code,
  dic_name,
  parent_code,
  create_time,
  operate_time
FROM base_dic
WHERE \$CONDITIONS" \
--num-mappers 1 \
--fields-terminated-by '\t' \
--compress \
--compression-codec gzip \
--null-string '\\N' \
--null-non-string '\\N'


# ======================================================================
#                 todo：2. 品牌表：base_trademark（首日，全量）
# ======================================================================
/opt/module/sqoop/bin/sqoop import \
--connect jdbc:mysql://node101:3306/gmall \
--username root \
--password 123456 \
--target-dir /origin_data/gmall/db/base_trademark/2024-01-06 \
--delete-target-dir \
--query "SELECT
  id,
  tm_name
FROM base_trademark
WHERE \$CONDITIONS" \
--num-mappers 1 \
--fields-terminated-by '\t' \
--compress \
--compression-codec gzip \
--null-string '\\N' \
--null-non-string '\\N'


# ======================================================================
#            todo：3. 三级分类表：base_category3（首日，全量）
# ======================================================================
/opt/module/sqoop/bin/sqoop import \
--connect jdbc:mysql://node101:3306/gmall \
--username root \
--password 123456 \
--target-dir /origin_data/gmall/db/base_category3/2024-01-06 \
--delete-target-dir \
--query "SELECT
  id,
  name,
  category2_id
FROM base_category3
WHERE \$CONDITIONS" \
--num-mappers 1 \
--fields-terminated-by '\t' \
--compress \
--compression-codec gzip \
--null-string '\\N' \
--null-non-string '\\N'


# ======================================================================
#             todo：4. 二级分类表：base_category2（首日，全量）
# ======================================================================
/opt/module/sqoop/bin/sqoop import \
--connect jdbc:mysql://node101:3306/gmall \
--username root \
--password 123456 \
--target-dir /origin_data/gmall/db/base_category2/2024-01-06 \
--delete-target-dir \
--query "SELECT
  id,
  name,
  category1_id
FROM base_category2
WHERE \$CONDITIONS" \
--num-mappers 1 \
--fields-terminated-by '\t' \
--compress \
--compression-codec gzip \
--null-string '\\N' \
--null-non-string '\\N'



# ======================================================================
#               todo：5. 一级分类表：base_category1（首日，全量）
# ======================================================================
/opt/module/sqoop/bin/sqoop import \
--connect jdbc:mysql://node101:3306/gmall \
--username root \
--password 123456 \
--target-dir /origin_data/gmall/db/base_category1/2024-01-06 \
--delete-target-dir \
--query "SELECT
  id,
  name
FROM base_category1
WHERE \$CONDITIONS" \
--num-mappers 1 \
--fields-terminated-by '\t' \
--compress \
--compression-codec gzip \
--null-string '\\N' \
--null-non-string '\\N'


# ======================================================================
#                todo：6. 库存单元表（商品信息表）：sku_info（首日，全量）
# ======================================================================
/opt/module/sqoop/bin/sqoop import \
--connect jdbc:mysql://node101:3306/gmall \
--username root \
--password 123456 \
--target-dir /origin_data/gmall/db/sku_info/2024-01-06 \
--delete-target-dir \
--query "SELECT
  id,
  spu_id,
  price,
  sku_name,
  sku_desc,
  weight,
  tm_id,
  category3_id,
  is_sale,
  create_time
FROM sku_info
WHERE \$CONDITIONS" \
--num-mappers 1 \
--fields-terminated-by '\t' \
--compress \
--compression-codec gzip \
--null-string '\\N' \
--null-non-string '\\N'


# ======================================================================
#                todo：7. 商品表：spu_info（首日，全量）
# ======================================================================
/opt/module/sqoop/bin/sqoop import \
--connect jdbc:mysql://node101:3306/gmall \
--username root \
--password 123456 \
--target-dir /origin_data/gmall/db/spu_info/2024-01-06 \
--delete-target-dir \
--query "SELECT
  id,
  spu_name,
  category3_id,
  tm_id
FROM spu_info
WHERE \$CONDITIONS" \
--num-mappers 1 \
--fields-terminated-by '\t' \
--compress \
--compression-codec gzip \
--null-string '\\N' \
--null-non-string '\\N'


# ======================================================================
#                 todo：8. 活动表：activity_info（首日，全量）
# ======================================================================
/opt/module/sqoop/bin/sqoop import \
--connect jdbc:mysql://node101:3306/gmall \
--username root \
--password 123456 \
--target-dir /origin_data/gmall/db/activity_info/2024-01-06 \
--delete-target-dir \
--query "SELECT
  id,
  activity_name,
  activity_type,
  start_time,
  end_time,
  create_time
FROM activity_info
WHERE \$CONDITIONS" \
--num-mappers 1 \
--fields-terminated-by '\t' \
--compress \
--compression-codec gzip \
--null-string '\\N' \
--null-non-string '\\N'



# ======================================================================
#                 todo：9. 优惠规则：activity_rule（首日，全量）
# ======================================================================
/opt/module/sqoop/bin/sqoop import \
--connect jdbc:mysql://node101:3306/gmall \
--username root \
--password 123456 \
--target-dir /origin_data/gmall/db/activity_rule/2024-01-06 \
--delete-target-dir \
--query "SELECT
  id,
  activity_id,
  activity_type,
  condition_amount,
  condition_num,
  benefit_amount,
  benefit_discount,
  benefit_level
FROM activity_rule
WHERE \$CONDITIONS" \
--num-mappers 1 \
--fields-terminated-by '\t' \
--compress \
--compression-codec gzip \
--null-string '\\N' \
--null-non-string '\\N'


# ======================================================================
#                 todo：10. 购物车表：cart_info（首日，全量）
# ======================================================================
/opt/module/sqoop/bin/sqoop import \
--connect jdbc:mysql://node101:3306/gmall \
--username root \
--password 123456 \
--target-dir /origin_data/gmall/db/cart_info/2024-01-06 \
--delete-target-dir \
--query "SELECT
  id,
  user_id,
  sku_id,
  cart_price,
  sku_num,
  sku_name,
  create_time,
  operate_time,
  is_ordered,
  order_time,
  source_type,
  source_id
FROM cart_info
WHERE \$CONDITIONS" \
--num-mappers 1 \
--fields-terminated-by '\t' \
--compress \
--compression-codec gzip \
--null-string '\\N' \
--null-non-string '\\N'


# ======================================================================
#                todo：11. 商品收藏表：favor_info（首日，全量）
# ======================================================================
/opt/module/sqoop/bin/sqoop import \
--connect jdbc:mysql://node101:3306/gmall \
--username root \
--password 123456 \
--target-dir /origin_data/gmall/db/favor_info/2024-01-06 \
--delete-target-dir \
--query "SELECT
  id,
  user_id,
  sku_id,
  spu_id,
  is_cancel,
  create_time,
  cancel_time
FROM favor_info
WHERE \$CONDITIONS" \
--num-mappers 1 \
--fields-terminated-by '\t' \
--compress \
--compression-codec gzip \
--null-string '\\N' \
--null-non-string '\\N'


# ======================================================================
#                todo：12.  优惠券表：coupon_info（首日，全量）
# ======================================================================
/opt/module/sqoop/bin/sqoop import \
--connect jdbc:mysql://node101:3306/gmall \
--username root \
--password 123456 \
--target-dir /origin_data/gmall/db/coupon_info/2024-01-06 \
--delete-target-dir \
--query "SELECT
  id,
  coupon_name,
  coupon_type,
  condition_amount,
  condition_num,
  activity_id,
  benefit_amount,
  benefit_discount,
  create_time,
  range_type,
  limit_num,
  taken_count,
  start_time,
  end_time,
  operate_time,
  expire_time
FROM coupon_info
WHERE \$CONDITIONS" \
--num-mappers 1 \
--fields-terminated-by '\t' \
--compress \
--compression-codec gzip \
--null-string '\\N' \
--null-non-string '\\N'


# ======================================================================
#               todo：13. sku平台属性值关联表：sku_attr_value（首日，全量）
# ======================================================================
/opt/module/sqoop/bin/sqoop import \
--connect jdbc:mysql://node101:3306/gmall \
--username root \
--password 123456 \
--target-dir /origin_data/gmall/db/sku_attr_value/2024-01-06 \
--delete-target-dir \
--query "SELECT
  id,
  attr_id,
  value_id,
  sku_id,
  attr_name,
  value_name
FROM sku_attr_value
WHERE \$CONDITIONS" \
--num-mappers 1 \
--fields-terminated-by '\t' \
--compress \
--compression-codec gzip \
--null-string '\\N' \
--null-non-string '\\N'


# ======================================================================
#                todo：14. sku销售属性值：sku_sale_attr_value（首日，全量）
# ======================================================================
/opt/module/sqoop/bin/sqoop import \
--connect jdbc:mysql://node101:3306/gmall \
--username root \
--password 123456 \
--target-dir /origin_data/gmall/db/sku_sale_attr_value/2024-01-06 \
--delete-target-dir \
--query "SELECT
  id,
  sku_id,
  spu_id,
  sale_attr_value_id,
  sale_attr_id,
  sale_attr_name,
  sale_attr_value_name
FROM sku_sale_attr_value
WHERE \$CONDITIONS" \
--num-mappers 1 \
--fields-terminated-by '\t' \
--compress \
--compression-codec gzip \
--null-string '\\N' \
--null-non-string '\\N'


